package com.dcbeida.widget.scanitem;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.dcbeida.R;
import com.dcbeida.bean.DrguItemDetail;
import java.util.List;

public class DetailItemView extends ScanView<DrguItemDetail> {

    public DetailItemView(Context context) {
        super(context);
    }

    public DetailItemView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public DetailItemView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);

    }

    @Override
    protected void calculateCount(View headView, List<DrguItemDetail> list) {

    }

    @Override
    protected View getNoHeadView() {
        View hasHeadView = getHasHeadView();
        View lin_header = hasHeadView.findViewById(R.id.lin_header);
        lin_header.setVisibility(View.GONE);
        return hasHeadView;
    }

    @Override
    protected View getHasHeadView() {
        return LayoutInflater.from(getContext()).inflate(R.layout.gift_detail_with_parent_cancel_item, null);
    }

    @Override
    protected void setDataToView(View itemView, DrguItemDetail data) {
        TextView tv_name = (TextView) itemView.findViewById(R.id.tv_name);
        tv_name.setText(data.getDrugname());

        TextView tv_all_count = (TextView) itemView.findViewById(R.id.tv_all_count);
        tv_all_count.setText(data.getAllQuantity() + "");

        TextView tv_pihao = (TextView) itemView.findViewById(R.id.tv_pihao);
        tv_pihao.setText(getContext().getString(R.string.pihao, data.getBatchnumber()));

        TextView tv_yxq = (TextView) itemView.findViewById(R.id.tv_yxq);
        tv_yxq.setText(getContext().getString(R.string.yxq2, data.getExpiredate()));

        TextView tv_jgh = (TextView) itemView.findViewById(R.id.tv_jgh);
        tv_jgh.setText(data.getDrugcode());

        TextView tv_count = (TextView) itemView.findViewById(R.id.tv_count);
        tv_count.setText(data.getQuantity() + "盒");
        TextView tv_gl_orderId = (TextView) itemView.findViewById(R.id.tv_gl_orderId);
        tv_gl_orderId.setText(data.getOrderid());
        TextView tv_orderTime = (TextView) itemView.findViewById(R.id.tv_orderTime);
        tv_orderTime.setText(getContext().getString(R.string.buy_time, data.getOrdertime()));

    }

    @Override
    public void closeOperate() {

    }

    @Override
    public String getKey(DrguItemDetail data) {
        return data.getId() + "";
    }
}
